package org.jogdiary2011.controller.person;

import org.jogdiary2011.meta.PersonMeta;
import org.jogdiary2011.model.ExerciseResult;
import org.jogdiary2011.model.Person;
import org.jogdiary2011.service.PersonService;
import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

public class ShowController extends Controller {

    private PersonService personService = new PersonService();
    private PersonMeta meta = PersonMeta.get();
    
    @Override
    public Navigation run() throws Exception {
        
        Person person = personService.get(asKey(meta.key));
        requestScope("person", person);
        requestScope("exerciseResults", person.getExerciseResultsRefs().getModelList());
        
        System.out.println("ShowController#run");
        System.out.println(person.getNickName());
        for (ExerciseResult result : person.getExerciseResultsRefs().getModelList()) {
            System.out.println(result.getExerciseDate());
            System.out.println(result.getMenu());
            System.out.println(result.getDescription());
            
        }
        
        return forward("show.jsp");
    }
}
